package UI_vente;

import GestionPlannification.Piece;
import javax.swing.ImageIcon;

/**
 *
 * @author  Aude Legrand, Elsa Ferrare, Alexandre Becquet
 */
public class Panel_Piece extends javax.swing.JPanel {
    private Piece maPiece;
    private Frame_vente maFrame;

    /** Creates new form Panel_Piece */
    public Panel_Piece(Frame_vente frame,Piece p){
        this.maFrame=frame;
        this.maPiece=p;
        initComponents();
        this.jLabelNom.setText(p.getTitre());
        this.jLabelGenre.setText("Genre : "+p.getGenre().toString());
        String auteurs = p.getAuteursString();
        this.jLabelAuteurs.setText("Auteurs : "+auteurs);
        String acteurs = p.getActeursString();
        this.jLabelActeurs.setText("Acteurs : "+acteurs);
        
        ImageIcon icon = new ImageIcon("image/"+p.getId()+".jpg","Affiche");
        this.jLabelImage.setIcon(icon);
        
        if(p.isPlein()) {
            this.jButtonVoirPiece.setText("Complet");
            this.jButtonVoirPiece.setEnabled(false);
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabelNom = new javax.swing.JLabel();
        jLabelGenre = new javax.swing.JLabel();
        jLabelActeurs = new javax.swing.JLabel();
        jLabelAuteurs = new javax.swing.JLabel();
        jButtonVoirPiece = new javax.swing.JButton();
        jLabelImage = new javax.swing.JLabel();

        setBackground(new java.awt.Color(255, 255, 102));
        setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        setMaximumSize(new java.awt.Dimension(800, 180));
        setMinimumSize(new java.awt.Dimension(200, 157));
        setOpaque(false);
        setPreferredSize(new java.awt.Dimension(200, 200));
        addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                formMouseClicked(evt);
            }
        });
        setLayout(new java.awt.GridLayout(1, 2));

        jPanel1.setMaximumSize(new java.awt.Dimension(804, 157));
        jPanel1.setOpaque(false);
        jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabelNom.setText("Nom");
        jPanel1.add(jLabelNom, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, 20));

        jLabelGenre.setText("Genre");
        jPanel1.add(jLabelGenre, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 20, -1, 20));

        jLabelActeurs.setText("Acteurs");
        jPanel1.add(jLabelActeurs, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 60, -1, 20));

        jLabelAuteurs.setText("Auteurs");
        jPanel1.add(jLabelAuteurs, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 40, -1, 20));

        jButtonVoirPiece.setBackground(new java.awt.Color(102, 0, 0));
        jButtonVoirPiece.setForeground(new java.awt.Color(255, 255, 255));
        jButtonVoirPiece.setText("Voir");
        jButtonVoirPiece.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonVoirPieceActionPerformed(evt);
            }
        });
        jPanel1.add(jButtonVoirPiece, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 100, 240, 40));

        add(jPanel1);

        jLabelImage.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabelImage.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING);
        add(jLabelImage);
    }// </editor-fold>//GEN-END:initComponents

    private void formMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_formMouseClicked

    private void jButtonVoirPieceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonVoirPieceActionPerformed
        // TODO add your handling code here:
        this.maFrame.voirPiece(this.maPiece);
}//GEN-LAST:event_jButtonVoirPieceActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonVoirPiece;
    private javax.swing.JLabel jLabelActeurs;
    private javax.swing.JLabel jLabelAuteurs;
    private javax.swing.JLabel jLabelGenre;
    private javax.swing.JLabel jLabelImage;
    private javax.swing.JLabel jLabelNom;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration//GEN-END:variables

}
